Number Functions
Table of Contents
1. Rounding Functions
1.1 ROUND
Task 1 – Round a number to different decimal places Write a query that:
-
Starts from the number
3.516(aliased asoriginal_number) -
Rounds it to:
- 2 decimal places (alias:
round_2) - 1 decimal place (alias:
round_1) - 0 decimal places (alias:
round_0)
- 2 decimal places (alias:
Using the ROUND() function.
💡 Suggested Answers
SELECT
3.516 AS original_number,
ROUND(3.516, 2) AS round_2,
ROUND(3.516, 1) AS round_1,
ROUND(3.516, 0) AS round_0
2. Absolute Value Function
2.1 ABS
Task 2 – Demonstrate the ABS (absolute value) function Write a query that:
- Shows
-10asoriginal_number - Returns the absolute value of
-10asabsolute_value_negative - Returns the absolute value of
10asabsolute_value_positive
Using the ABS() function.
💡 Suggested Answers
SELECT
-10 AS original_number,
ABS(-10) AS absolute_value_negative,
ABS(10) AS absolute_value_positive